package com.pn.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/*
  mp的配置类:
 */
//将mapper接口扫描注解标注在公共模块的mp的配置类上,然后所有的业务模块就可以
//通过引入公共模块进而引入mp的配置类同时也会引入mapper接口扫描注解,那么在所有
//业务模块的启动类上就无需在标注mapper接口扫描注解了
@MapperScan(basePackages = "com.pn.mapper")
@Configuration
public class MpConfig {

    /*
      配置mp的插件容器,然后向mp的插件容器中添加分页插件来配置分页插件:
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        //创建插件容器
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
        //向插件容器中添加分页插件
        mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor());
        //返回插件容器
        return mybatisPlusInterceptor;
    }
}
